package com.yehangtech.designpattern.结构型_装饰者.intercepet;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

public class LoginSsoDecorator extends SsoDecorator {

    private static ConcurrentMap<String, String> cache = new ConcurrentHashMap<>();

    static {
        cache.put("cjyyp", "getAllMesById");
    }

    public LoginSsoDecorator(HandlerInterceptor handlerInterceptor) {
        super(handlerInterceptor);
    }

    @Override
    public boolean preHandler(String request, String response, Object handler) {
        boolean preHandler = super.preHandler(request, response, handler);
        System.out.println("第一次验证结果为：" + preHandler);
        if (!preHandler) return false;
        String userID = request.substring(7);
        String method = cache.get(userID);
        System.out.println(userID);
        System.out.println(method);
        return "getAllMesById".equals(method);
    }
}
